package com.zn.controller;

import com.zn.common.constants.Constants;
import com.zn.common.resp.ApiResult;
import com.zn.common.utils.FileUtils;
import com.zn.pojo.VeiReportInfo;
import com.zn.services.VeiReportInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Deprecated
@RestController
@RequestMapping("android")
public class AndroidController {

    @Autowired
    private VeiReportInfoService veiReportInfoService;

    @PostMapping("/vei/upload")
    @ResponseBody
    public ApiResult<String> upload(@RequestBody VeiReportInfo info){
        base64toImage1(info);
        try {
            veiReportInfoService.addVeiReportInfo(Constants.REPORT_STATUS0,info,Constants.DEFAULT_USER_ID);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return new ApiResult<>();
    }

    private void base64toImage1(VeiReportInfo info){
        info.setFpic1(FileUtils.Base64ToImage(info.getFpic1()));
        info.setFpic2(FileUtils.Base64ToImage(info.getFpic2()));
        info.setFpic3(FileUtils.Base64ToImage(info.getFpic3()));
        info.setFpic4(FileUtils.Base64ToImage(info.getFpic4()));
        info.setFpic5(FileUtils.Base64ToImage(info.getFpic5()));
        info.setFpic6(FileUtils.Base64ToImage(info.getFpic6()));
        info.setFpic7(FileUtils.Base64ToImage(info.getFpic7()));
        info.setFpic8(FileUtils.Base64ToImage(info.getFpic8()));
        info.setFpic9(FileUtils.Base64ToImage(info.getFpic9()));
        info.setFpic10(FileUtils.Base64ToImage(info.getFpic10()));
    }
}
